{extend name='public/layout' /}
{block name='content'}
{include file='loupan/nav' /}
<div class="h_s_n3_t"><h1 class="h1_title"><span class="h1_title_t">楼盘问答</span></h1></div>
<div class="h_s_n3">
    <div class="ylj-store-comment ylj-padding-t-b">
        {fang:lists table='ask' where="house_id=$id and status=1" order='id desc' limit='5' page='true' id='data'}
        <div class="ylj-store-comment-box">
            <a href="javascript:;">
                <img class="ylj-avatar" src="{notempty name='data.user.headigurl'}{$data.user.headimgurl}{else /}__IMG__/head_logo.png{/notempty}" alt="{$data.user.nickname}">
            </a>
            <div class="ylj-store-comment-info">
                <h3>
                    {empty name='data.user_id'}匿名用户{else /}{$data.user_name}{/empty}&nbsp;&nbsp;
                    {$data.create_time|date='Y-m-d H:i:s',###}
                </h3>
                <div class="ylj-comment-content">
                    <a href="{:url('Question/detail',['id'=>$data['id']])}">{$data.content}</a>
                </div>
                {php}$askid=$data['id'];{/php}
                {fang:lists table='answer' where="ask_id=$askid and status=1" order='id desc' limit='5' empty='暂无回答' id='vo'}
                <div class="ylj-comment-relpy">
                    <span>[{$vo.user.nickname}回复]</span>{$vo.content}
                </div>
                {/fang:lists}
            </div>
        </div>
        {/fang:lists}
    </div>
</div>
<div class="plastic_bottom_pages">
    {$pages}
</div>

<div class="div_box">
    <div class="h_s_n3_t"><h1 class="h1_title"><span class="h1_title_t">在线问答</span></h1></div>
    <form action="{:url('Ajax/question')}" method="post" id="form">
    <div class="ask_show01_n2 regbox" style="padding: 10px;">
        <p>问题标题<span class="org">*</span></p>
        <p><input class="input_reg" id="title" name="title" type="text"></p>
        <p>问题详细<span class="org">*</span></p>
        <p>
            <textarea id="content" class="r_inp01" name="content"></textarea>
        </p>
        <p>所属分类<span class="org">*</span></p>
        <p class="overflow_h">
              <span class="address_sel" style="width: 100%">
                  <select class="select01"  id="cate_id" name="cate_id">
                      <option value="0">--请选择分类--</option>
                      {volist name='ask_cate' id='val'}
                      <option value="{$val.id}" {present name="val._child"}disabled{/present}>{$val.name}</option>
                      {present name='val._child'}
                      {volist name='val._child' id='vo'}
                      <option value="{$vo.id}">--{$vo.name}</option>
                      {/volist}
                      {/present}
                      {/volist}
                  </select>
              </span>
        </p>
        <p><a id="askBut" href="javascript:;" class="but03">提交问题</a></p>
        <input type="hidden" value="{$info.id}" name="house_id" id="house_id">
    </div>
    </form>
</div>
<script src="__PUBLIC__/js/layer/layer.js"></script>
<script src="__PUBLIC__/js/plugins/jquery.ajax.form.js"></script>
<script>
    $(function(){
        $('#askBut').bind('click',function(){
            var title = $('#title').val();
            var content = $('#content').val();
            var cate_id = $('#cate_id').val();
            if(title.length==0){
                layer.msg('请填写标题',{icon:2});
                return false;
            }
            if(content.length==0){
                layer.msg('请填写内容',{icon:2});
                return false;
            }
            if(cate_id==0){
                layer.msg('请选择分类',{icon:2});
                return false;
            }
            layer.load(1);
            $('#form').submit();
        });
        $('#form').ajaxForm({success:complate,dataType:'json'});
        function complate(result){
            layer.closeAll();
            if(result.status == 1){
                layer.msg(result.msg,{icon:1});
                setTimeout(function(){window.location.href=window.location.href+'?t='+Math.random();},3000);
            } else {
                layer.msg(result.msg,{icon:2});
            }
        }
    });
</script>
{/block}